int m_socket; BOOL m_bIsValid; SOCKADDR_IN m_sin; char m_remote_machine[100]; short m_remote_port = 2727; struct hostent *h; WORD wVersionRequested; WSADATA wsaData; int err; strcpy(m_remote_machine,"HARDMAN\0"); memset(&m_sin, 0, sizeof(m_sin)); bzero((char *)&m_sin, sizeof(m_sin)); m_sin.sin_port = htons((u_short)m_remote_port); m_sin.sin_family = AF_INET; wVersionRequested = MAKEWORD( 2, 2 ); err = WSAStartup( wVersionRequested, &wsaData ); if(m_remote_machine[0] < '0' || m_remote_machine[0] > '9' ) { if( !(h=gethostbyname(m_remote_machine)) ) { m_bIsValid = FALSE; return; } memcpy(&m_sin.sin_addr, h->h_addr, sizeof(m_sin.sin_addr)); } else { char* pBuf = m_remote_machine; m_sin.sin_addr.S_un.S_un_b.s_b1 = (unsigned char)atoi(m_remote_machine); pBuf = strchr(pBuf, '.'); if(!pBuf) return; pBuf++; m_sin.sin_addr.S_un.S_un_b.s_b2 = (unsigned char)atoi(pBuf); pBuf = strchr(pBuf, '.'); if(!pBuf) return; pBuf++; m_sin.sin_addr.S_un.S_un_b.s_b3 = (unsigned char)atoi(pBuf); pBuf = strchr(pBuf, '.'); if(!pBuf) return; pBuf++; m_sin.sin_addr.S_un.S_un_b.s_b4= (unsigned char)atoi(pBuf); } m_socket = socket(AF_INET, SOCK_DGRAM, 0); if( m_socket==INVALID_SOCKET ) { m_bIsValid = FALSE; return; } sendto(m_socket, "SIP", strlen("SIP"), 0, (struct sockaddr*)&m_sin, sizeof(m_sin));